package org.ch02.hw.demo03;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

/**
 * 遍历Integer类中所有的字段
 *
 * @author lwj
 * @date 2025-03-17
 * @vesion 1.0.0
 */
public class MainTest01 {
    public static void main(String[] args) throws Exception {
        // 获取 Class 对象
        Class<Integer> clazz = Integer.class;

        // 获取字段对象
        Field[] declaredFields = clazz.getDeclaredFields();
        System.out.println(" "+clazz.getSimpleName()+"{");
        // 遍历字段
        for (Field field : declaredFields) {
            Class<?> type = field.getType();
            System.out.println("\t"+Modifier.toString(field.getModifiers())+" "+type.getSimpleName()+" "+field.getName()+";");
        }
        System.out.println("}");
    }
}
